home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 570 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  997 b 

  1. Path: solon.com!not-for-mail
  2. From: thads@csn.net (Thad Smith)
  3. Newsgroups: comp.lang.c.moderated,comp.std.c
  4. Subject: Re: 'h' modifier in printf
  5. Date: 14 Mar 1996 21:23:38 -0600
  6. Organization: T3 Systems
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4ianrq$het@solutions.solon.com>
  10. References: <4i801c$455@solutions.solon.com> <4i98fl$8ml@solutions.solon.com>
  11. Reply-To: ThadSmith@acm.org
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4i98fl$8ml@solutions.solon.com>,
  15. baynes@ukpsshp1.serigate.philips.nl wrote:
  16.  
  17. >: int i;
  18. >: printf("%hd", i);
  19. >: printf("%d", (short)i);
  20. >
  21.  
  22. >I think if the value of i is outside SHRT_MIN to SHRT_MAX then both are
  23. >undefined for different reasons. The first printf (%hd) because the conversion
  24. >does not apply to a short integer. The second printf (%d of (short)) because
  25. >the cast of i to (short) is not defined when i is out of range. 
  26.  
  27. Actually the result of the conversion in the second printf is
  28. implementaion-defined.
  29.  
  30. Thad
  31.